<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>径向渐变实现舞台灯光聚焦效果</title>
  <style>
    html,
    body {
      width: 100%;
      height: 100%;
      /* background-image: url(https://images.unsplash.com/photo-1440688807730-73e4e2169fb8?dpr=1&auto=format&fit=crop&w=1500&h=1001&q=80&cs=tinysrgb&crop=); */
      background-image: url(img/3.jpg);
      background-repeat: no-repeat;
      background-size: cover;
      overflow: hidden;
    }

    .radial-circle {
      position: absolute;
      top: -100%;
      left: -100%;
      right: -100%;
      bottom: -100%;
      background: radial-gradient(circle at 50% 50%, transparent 0%, transparent 3%, rgba(0, 0, 0, .7) 3.5%, rgba(0, 0, 0, .8) 100%);
      animation: move 10s infinite alternate;
    }

    @keyframes move {
      0% {
        transform: translateX(-10%);
      }

      100% {
        transform: translateX(10%);
      }
    }
  </style>
</head>

<body>
  <div class="radial-circle"></div>

  <script>
    var a = 2;
    function abc() {
      /*
      console.log(a);
      var a = 3;
      相当于
      var a;
      console.log(a);
      a = 3;
      */

      /*变量作用域名问题
      优先查看当前作用域是否定义，
      当前作用域高于全局定义的，
      打印undefined
      */
      // alert(a);
      console.log(a);
      var a = 3;
    }
    abc();
    function abcd() {
      /*变量作用域名问题
      局部变量未定义，所以输出全局变量
      */
      // alert(a);
      console.log(a);
    }
    abcd();
    console.log(writeLine(6, '全局局部作用域结束'));

    /*如果函数与变量同名，那么函数声明会替换变量*/
    console.log(b);
    function b() {
      console.log('b');
    }
    var b = 1;
    console.log(b);
    /*如果函数与变量同名，那么函数声明会替换变量。如果函数声明未调用，则后面赋值操作覆盖前面，输出11*/
    console.log(writeLine(6, ''));
    function bb() {
      console.log('b');
    }

    var bb = 11;
    console.log(bb);
    console.log(writeLine(6, '变量方法结束'));

    /*输出横线*/
    function writeLine(n, tip) {
      var line = '';
      for (var i = 0; i < n; i++) {
        if (i == parseInt((n / 2))) {
          line += tip + '-';
        }
        else {
          line += '-';
        }
      }
      return line;
    }
  </script>
</body>

</html>